home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Cursor;
- import java.awt.Event;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.LayoutManager;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.InputStreamReader;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.net.URLEncoder;
-
- public class Graph extends Applet implements MouseListener {
- // $FF: renamed from: wi int
- private int field_0;
- // $FF: renamed from: he int
- private int field_1;
- private int NCol;
- private int NRow;
- private float[][] data;
- private Color backColor;
- private String statusBarText;
- private String link;
- // $FF: renamed from: b java.awt.Graphics
- private Graphics field_2;
- private Image buffer;
- private String xLabel;
- private String yLabel;
- private String title;
- private final Color[] colors;
- private float xmin;
- private float xmax;
- private float ymin;
- private float ymax;
- private boolean linked;
- private int border;
- private Color borderColor;
-
- public String getAppletInfo() {
- return "Name: Graph\r\nAuthor: Taiji Software";
- }
-
- public void register() {
- try {
- URL u = new URL("http://www.taijisoftware.com");
- ((Applet)this).getAppletContext().showDocument(u, "_blank");
- } catch (Exception e) {
- System.out.println(e);
- this.stop();
- }
- }
-
- public void init() {
- String codeBase = null;
-
- try {
- codeBase = (new URL(((Applet)this).getCodeBase().toString())).getHost();
- System.out.println("Copyright 1999, 2001 Taiji Software(tm)\nYour domain name is : " + codeBase);
- codeBase = codeBase.toUpperCase();
- } catch (Exception var9) {
- }
-
- if (!((Applet)this).getCodeBase().toString().toUpperCase().startsWith("FILE") || ((Applet)this).getParameter("debug") != null) {
- String regCode = ((Applet)this).getParameter("registration_code");
- if (regCode == null) {
- regCode = ((Applet)this).getParameter("reg_domain");
- if (regCode == null) {
- this.register();
- } else {
- if (regCode.length() == codeBase.length() + 4 && !codeBase.startsWith("WWW.")) {
- codeBase = "WWW." + codeBase;
- } else if (regCode.length() == codeBase.length() - 4 && codeBase.startsWith("WWW.")) {
- codeBase = codeBase.substring(4);
- }
-
- char[] chars = new char[codeBase.length()];
- codeBase.getChars(0, codeBase.length(), chars, 0);
- String key = new String("haricot");
- char[] chars2 = new char[key.length()];
- key.getChars(0, key.length(), chars2, 0);
-
- for(int i = 0; i < codeBase.length(); ++i) {
- int j;
- if (i >= key.length()) {
- j = i - key.length() * (i / key.length());
- } else {
- j = i;
- }
-
- chars[i] += chars2[j];
- chars[i] = (char)(chars[i] - chars[i] / 26 * 26 + 97);
- }
-
- String res = new String(chars);
- if (!res.equalsIgnoreCase(regCode)) {
- this.register();
- }
- }
- } else if (!regCode.equals("settevercsedegnamiaj") && !regCode.equals("8078")) {
- this.register();
- }
- }
-
- this.getParameters();
-
- try {
- String s = "";
- InputStream in = null;
- in = (new URL(((Applet)this).getCodeBase(), ((Applet)this).getParameter("data_file"))).openStream();
- BufferedReader br = new BufferedReader(new InputStreamReader(in));
-
- while((s = br.readLine()) != null) {
- try {
- if (this.NCol == 0) {
- int p;
- while((p = s.indexOf(" ")) != -1) {
- ++this.NCol;
- s = s.substring(p + 1);
- }
-
- ++this.NCol;
- }
-
- ++this.NRow;
- } catch (Exception var12) {
- }
- }
-
- br.close();
- } catch (IOException e) {
- System.out.println("data file read error !" + e);
- }
-
- ((Component)this).setBackground(this.backColor);
- this.data = new float[this.NRow][this.NCol];
-
- try {
- String s = "";
- InputStream in = null;
- in = (new URL(((Applet)this).getCodeBase(), ((Applet)this).getParameter("data_file"))).openStream();
- BufferedReader br = new BufferedReader(new InputStreamReader(in));
- int i = 0;
-
- while(true) {
- s = br.readLine();
- if (s == null) {
- br.close();
- break;
- }
-
- try {
- for(int j = 0; j < this.NCol - 1; ++j) {
- int p = s.indexOf(" ");
- this.data[i][j] = Float.valueOf(s.substring(0, p));
- s = s.substring(p + 1);
- }
-
- this.data[i][this.NCol - 1] = Float.valueOf(s);
- } catch (Exception var10) {
- }
-
- ++i;
- }
- } catch (IOException e) {
- System.out.println("data file read error !" + e);
- }
-
- this.xmin = 0.0F;
- this.xmax = 0.0F;
- this.ymin = 0.0F;
- this.ymax = 0.0F;
-
- for(int i = 0; i < this.NRow; ++i) {
- if (this.data[i][0] < this.xmin) {
- this.xmin = this.data[i][0];
- }
-
- if (this.data[i][0] > this.xmax) {
- this.xmax = this.data[i][0];
- }
-
- for(int j = 1; j < this.NCol; ++j) {
- if (this.data[i][j] < this.ymin) {
- this.ymin = this.data[i][j];
- }
-
- if (this.data[i][j] > this.ymax) {
- this.ymax = this.data[i][j];
- }
- }
- }
-
- String s = ((Applet)this).getParameter("xmin");
- if (s != null) {
- this.xmin = Float.valueOf(s);
- }
-
- s = ((Applet)this).getParameter("ymin");
- if (s != null) {
- this.ymin = Float.valueOf(s);
- }
-
- ((Container)this).setLayout((LayoutManager)null);
- this.buffer = ((Component)this).createImage(this.field_0, this.field_1);
- this.field_2 = this.buffer.getGraphics();
- ((Component)this).repaint();
- }
-
- public void update(Graphics g) {
- this.paint(g);
- }
-
- public void paint(Graphics g) {
- if (this.border > 0) {
- this.field_2.setColor(this.borderColor);
-
- for(int i = 0; i < this.border; ++i) {
- this.field_2.drawRect(i, i, this.field_0 - 2 * i - 1, this.field_1 - 2 * i - 1);
- }
- }
-
- int x0 = (int)((double)this.field_0 / (double)10.0F);
- int y0 = this.field_1 - (int)((double)this.field_1 / (double)10.0F);
- this.field_2.setColor(Color.black);
- this.field_2.drawLine(x0, y0, this.field_0 - x0, y0);
- this.field_2.drawLine(x0 + 1, y0 + 1, this.field_0 - x0, y0 + 1);
- this.field_2.drawLine(x0, y0, x0, this.field_1 - y0);
- this.field_2.drawLine(x0 + 1, y0 + 1, x0 + 1, this.field_1 - y0);
- Font f = this.field_2.getFont();
- this.field_2.setFont(new Font("TimesRoman", 1, this.field_1 - y0));
- FontMetrics fm = this.field_2.getFontMetrics();
- int longueur = fm.stringWidth(this.title);
- this.field_2.drawString(this.title, (this.field_0 - longueur) / 2, (int)((double)(this.field_1 - y0) * 0.9));
- f = this.field_2.getFont();
- this.field_2.setFont(new Font(f.getName(), 1, (this.field_1 - y0) / 2));
- fm = this.field_2.getFontMetrics();
- longueur = fm.stringWidth(this.xLabel);
- this.field_2.drawString(this.xLabel, this.field_0 - longueur - 10, this.field_1 - (int)((double)(this.field_1 - y0) / (double)5.0F));
- this.field_2.drawString(this.yLabel, 10, this.field_1 - y0 - 10);
- int xb = 0;
- int yb = 0;
- boolean first = true;
-
- for(int j = 1; j < this.NCol; ++j) {
- this.field_2.setColor(this.colors[j - 1]);
- first = true;
-
- for(int i = 0; i < this.NRow; ++i) {
- int x = x0 + (int)((this.data[i][0] - this.xmin) * (float)(this.field_0 - 2 * x0 - 10) / (this.xmax - this.xmin));
- int y = y0 - (int)((this.data[i][j] - this.ymin) * (float)(y0 - (this.field_1 - y0) - 10) / (this.ymax - this.ymin));
- this.field_2.fillOval(x - 4, y - 4, 8, 8);
- if (first) {
- first = false;
- } else if (this.linked) {
- this.field_2.drawLine(xb, yb, x, y);
- }
-
- xb = x;
- yb = y;
- }
- }
-
- this.field_2.setColor(Color.black);
- this.field_2.setFont(new Font(f.getName(), 1, (int)((double)(this.field_1 - y0) * 0.3)));
- fm = this.field_2.getFontMetrics();
- String s = Float.toString(this.xmin);
- this.field_2.drawString(s, x0 - fm.stringWidth(s) / 3, y0 + (int)((double)(this.field_1 - y0) * 0.4));
- s = Float.toString(this.ymin);
- this.field_2.drawString(s, x0 - (int)((double)fm.stringWidth(s) * 1.2), y0);
- s = Float.toString(this.xmax);
- this.field_2.drawString(s, this.field_0 - x0 - fm.stringWidth(s) / 2, y0 + (int)((double)(this.field_1 - y0) * 0.4));
- s = Float.toString(this.ymax);
- this.field_2.drawString(s, x0 - (int)((double)fm.stringWidth(s) * 1.2), (int)((double)(this.field_1 - y0) * 1.2));
- g.drawImage(this.buffer, 0, 0, this);
- }
-
- public void stop() {
- }
-
- public void getParameters() {
- this.field_0 = ((Component)this).getSize().width;
- this.field_1 = ((Component)this).getSize().height;
- if (this.getColor("background_color") != null) {
- this.backColor = this.getColor("background_color");
- }
-
- this.link = ((Applet)this).getParameter("link");
- this.statusBarText = ((Applet)this).getParameter("status_bar_text");
- this.xLabel = ((Applet)this).getParameter("xlabel_title");
- this.yLabel = ((Applet)this).getParameter("ylabel_title");
- this.title = ((Applet)this).getParameter("title");
- if (((Applet)this).getParameter("linked").equals("yes")) {
- this.linked = true;
- }
-
- String s = ((Applet)this).getParameter("border");
- if (s != null) {
- this.border = Integer.parseInt(s);
- }
-
- if (this.getColor("border_color") != null) {
- this.borderColor = this.getColor("border_color");
- }
-
- }
-
- private Color getColor(String param) {
- String s = ((Applet)this).getParameter(param);
- if (s != null) {
- if (s.substring(0, 1).equals("#")) {
- s = s.substring(1);
- int i = Integer.parseInt(s, 16);
- return new Color(i);
- } else {
- return null;
- }
- } else {
- return null;
- }
- }
-
- public boolean action(Event evt, Object obj) {
- return true;
- }
-
- public URL giveURL(String url) {
- try {
- if (url.toUpperCase().startsWith("HTTP")) {
- return new URL(url);
- } else if (url.toUpperCase().startsWith("FTP")) {
- int p = url.indexOf(":");
- int p2 = url.indexOf(":", p + 1);
- if (p2 != -1) {
- url = url.substring(0, p + 3) + URLEncoder.encode(url.substring(p + 3, url.length()));
- }
-
- p = url.indexOf("%40");
- if (p != -1) {
- url = url.substring(0, p) + "@" + url.substring(p + 3, url.length());
- }
-
- return new URL(url);
- } else {
- return new URL(((Applet)this).getCodeBase(), url);
- }
- } catch (MalformedURLException e) {
- System.out.println(e);
- return null;
- }
- }
-
- public Graph() {
- this.colors = new Color[]{Color.blue, Color.red, Color.yellow, Color.green, Color.black};
- this.backColor = Color.white;
- ((Component)this).addMouseListener(this);
- }
-
- public void mouseClicked(MouseEvent e) {
- }
-
- public void mouseEntered(MouseEvent e) {
- if (this.statusBarText != null) {
- ((Applet)this).showStatus(this.statusBarText);
- }
-
- if (this.link != null) {
- ((Component)this).setCursor(new Cursor(12));
- }
-
- }
-
- public void mouseExited(MouseEvent e) {
- if (this.link != null) {
- ((Component)this).setCursor(new Cursor(0));
- }
-
- }
-
- public void mousePressed(MouseEvent e) {
- if (this.link != null) {
- String target = ((Applet)this).getParameter("target");
- if (target == null) {
- target = "_blank";
- }
-
- URL u = this.giveURL(this.link);
- ((Applet)this).getAppletContext().showDocument(u, target);
- }
-
- }
-
- public void mouseReleased(MouseEvent e) {
- }
- }
-